﻿Imports System.Data
Imports VSModel
Imports Cls_Common
Imports SecurityService
Partial Class FrontEnd_Control_ToolLikeCmt_BoxlikeCmtToolBar
    Inherits System.Web.UI.UserControl
    Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
        If Not Page.IsPostBack Then
            If Page.RouteData.Values("Id") <> "" Then
                hidId.Value = Page.RouteData.Values("Id")
                If hidId.Value = "" Then
                    hidId.Value = 0
                End If
            End If
            BindMenu()
        End If
    End Sub
    Protected Sub BindMenu()
        Using data As New VSEntities
            'ParenId = 0 Menu cha
            'MenuPosition = 1 hien thi tren menu
            Dim d = (From p In data.Contents Where p.Id = hidId.Value Select p).FirstOrDefault

            Dim Url = MainDomain & "m/" & d.QueryString & "-" & d.Id & ".html"
            'share facebook
            ltrShareFacebook.Text = "<a href='javascript:void(0);' class='badge-facebook-share  btn-share  facebook' data-evt='Facebook-Share,PostClicked," & Url & "' data-share='" & Url & "'>Facebook</a>"
            'share twitter
            ltrShareTwitter.Text = "<a target='_blank' href='javascript:void(0);' class='badge-twitter-share btn-share twitter' data-evt='Twitter-Share,ListClicked," & Url & "' data-title = '" & d.Title & "' data-share='" & Url & "'>Twitter</a>"
            'share GPlus
            ltrShareGPlus.Text = "<a href='javascript:void(0);' class='badge-gplus-share badge-evt badge-track' data-evt='GPlus-Share,PostClicked," & Url & "' data-share='" & Url & "'>Google+</a>"
            'share Pinterest
            ltrSharePinterest.Text = "<a href='javascript:void(0);' class='badge-pinterest-share badge-evt badge-track' data-evt='Pinterest-Share,PostClicked," & Url & "' data-title='" & d.Title & "' data-share='" & Url & "'>Pinterest</a>"

            'lay tin tiep theo cua loai tin
            Dim _NewPost = (From p In data.Contents Where p.Id <> hidId.Value Order By p.Created Descending Select p).FirstOrDefault
            Dim _Url = MainDomain & "m/" & _NewPost.QueryString & "-" & _NewPost.Id & ".html"
            ltrNextPost.Text = "<a class='badge-fast-entry badge-next-post-entry next ' href='" & _Url & "'><span class='label'>Next Post</span><span class='arrow'></span></a>"
        End Using
    End Sub
End Class
